<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script>
  // 箭头函数，用来简化匿名函数
  let fun1 = function () {

    console.log("普通无参数匿名");
  }
  fun1()


  // es6
  let fun2 = () => {
    console.log("这是箭头函数1");
  }
  fun2()
  // 去除花括号
  let fun3 = () => console.log("箭头函数2");
  fun3()




  // 带参数的
  let c = "454"

  let fun4 = (c) => {
    // let c = "454"//let不能重复定义
    console.log("带参数的", c);
  }
  fun4(c)

  // 带多个参数的
  let c1 = "456"

  let fun5 = (c1, r) => {
    // let c = "454"//let不能重复定义
    console.log("带参数的fun5", c1, r);
  }
  let r = "123"//let 只要在函数调用前就行
  fun5(c1, r)
  // let r = "123"//let 只要在函数调用前就行，在调用后会报错
  // 需要大括号的情况，计算
  let fun6 = (s, q) => {
    let sum = s + q
    return sum;
  }
  console.log("\n以下是fun6");
  console.log(fun6(true, false));//1是真，0是假，返回1
  console.log(fun6(true, true));//返回2
  console.log(fun6(56, 1));
  console.log(fun6("true", "false"));
  console.log(fun6(56, "wd"));

</script>

<body>

</body>

</html>